package Controller.Actions.Delete;

import Controller.*;
import java.io.*;
import java.net.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import Model.Beans.Results.*;
import Model.Beans.*;
import Model.QBE.*;

public class DeleteScheduleAction implements Action {
    
    private String name;
    
    public DeleteScheduleAction() 
    {
        this.name = "DeleteSchedule";
    }    
    
    public String getName()
    {
        return name;
    }
    
    public void perform(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException
    {
        ScheduleModel model = new ScheduleModel();
        String student_id = request.getParameter("student_id");
        String course_id = request.getParameter("course_id");
        
        Schedule schedule = new Schedule();
        schedule.setCourseId(Integer.parseInt(course_id));
        schedule.setStudentId(Integer.parseInt(student_id));
        
        
        if(model.delete(schedule) != 0)
        {
            response.getWriter().write("<message> The schedule has been successfully deleted </message>");
        }
        else
        {
            response.getWriter().write("<message>The schedule doesn't exists </message>");
        }
    }
}
